﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.1/themes/default/easyui.css" />  
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.1/themes/icon.css" />  
    <script type="text/javascript" src="jquery-easyui-1.3.1/jquery.easyui.min.js"></script>  
    <script type="text/javascript" src="jquery-easyui-1.3.1/locale/easyui-lang-en.js"></script>
</head>
<body>
    <h3>Category Type:</h3>    
    <div class='input-control select'>
        <select id="idAddCategory">
            <option value='1'>Income</option>
            <option value='2'>Expense</option>
        </select>
    </div>
    <h3>Category Name:</h3>   
    <div class='input-control text'>
        <input type='text' placeholder='Enter Name' id="idCategoryName"/>
        <button class='helper'></button>
    </div>
    <button id='btnSaveCategory' class='bg-color-orange fg-color-white' style='position:relative; float:right;'>Save</button>

</body>
<script type="text/javascript">
    $(document).ready(function ()
    {
        $('#idCategoryName').focus();

        $('#btnSaveCategory').click(function ()
        {
            var record = $('#idAddCategory').val() + '|' + $('#idCategoryName').val();
            $.ajax({
                type: "POST",
                url: "General.ashx",
                data: "mode=AddCategory&record=" + record,
                async: false,
                success: function (data)
                {
                    if ('True' == data)
                    {
                        if (confirm('Do you want to add another category?'))
                        {
                            //$('#idAddCategory').attr('value', 0);
                            $('#idCategoryName').attr('value', '');
                            $('#idCategoryName').focus();
                        }
                        else //go back to previous level
                        {
                            $('#btnCategory').click();
                        }
                    }
                    else
                    {
                        alert('Server is busy, please try it later!');
                    }
                }
            });
        });
    });
</script>
</html>
